import { Root } from "../../../../Core/Module/Entity/Root";
import { AEvent } from "../../../../Core/Module/EventSystem/IEvent";
import { EventAttribute } from "../../../../Decorator/Decorator";
import { ETTask } from "../../../../Support/Share/Lib/Async/ETTask";
import { SceneFactory } from "../../../Hotfix/Client/Demo/Scene/SceneFactory";
import { EntryEventType } from "../../../Model/Share/Entry";
import { PanelId } from "../../../ModelView/Client/Demo/FUIAutoGen/PanelId";
import { FUIGlobalComponent } from "../../../ModelView/Client/Demo/Global/FUIGlobalComponent";
import { FUIAssetComponent } from "../../../ModelView/Client/Plugins/FairyGUI/FUIAssetComponent";
import { FUIComponent } from "../../../ModelView/Client/Plugins/FairyGUI/FUIComponent";
import { FUIEventComponent } from "../../../ModelView/Client/Plugins/FairyGUI/FUIEventComponent";

@EventAttribute(EntryEventType.EntryEvent3)
export class EntryEvent3_InitClient extends AEvent<EntryEventType.EntryEvent3> {

    async Run(a: EntryEventType.EntryEvent3): Promise<any> {
        Root.Instance.Scene.AddComponent<FUIGlobalComponent>(FUIGlobalComponent);

        let clientScene = await SceneFactory.CreateClientScene(1, "Cocos");

        clientScene.AddComponent<FUIAssetComponent>(FUIAssetComponent);
        clientScene.AddComponent<FUIComponent>(FUIComponent);
        clientScene.AddComponent<FUIEventComponent>(FUIEventComponent);

        clientScene.GetComponent<FUIComponent>(FUIComponent).ShowPanelAsync(PanelId.Login);

        await ETTask.CompletedTask;
    }

}